package com.example.demo.test;

import com.alibaba.fastjson.JSON;
import com.example.demo.pojo.vo.BksSchoolScore;
import com.example.demo.pojo.vo.BksSchoolScoreVO;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * @description 排序
 *
 * @author lilinchun
 * @date 2023/09/22
 */
public class demo7 {

    public static void main(String[] args) {
        List<BksSchoolScore> list = new ArrayList<>();
        BksSchoolScore bestScore = new BksSchoolScore();
        bestScore.setType("1")
                .setMinSection("395");
        BksSchoolScore bestScore1 = new BksSchoolScore();
        bestScore1.setType("1")
                .setMinSection("579");
        BksSchoolScore bestScore2 = new BksSchoolScore();
        bestScore2.setType("1")
                .setMinSection("794");
        BksSchoolScore bestScore3 = new BksSchoolScore();
        bestScore3.setType("1")
                .setMinSection("998");
        BksSchoolScore bestScore4 = new BksSchoolScore();
        bestScore4.setType("1")
                .setMinSection("1107");
        BksSchoolScore bestScore5 = new BksSchoolScore();
        bestScore5.setType("1")
                .setMinSection("1477");
        BksSchoolScore bestScore6 = new BksSchoolScore();
        bestScore6.setType("1")
                .setMinSection("3673");
        BksSchoolScore bestScore7 = new BksSchoolScore();
        bestScore7.setType("1")
                .setMinSection("5565");
        list.add(bestScore);
        list.add(bestScore1);
        list.add(bestScore2);
        list.add(bestScore3);
        list.add(bestScore4);
        list.add(bestScore5);
        list.add(bestScore6);
        list.add(bestScore7);
        List<BksSchoolScoreVO> bksSchoolScoreVOS = JSON.parseArray(JSON.toJSONString(list), BksSchoolScoreVO.class);
        BksSchoolScoreVO bksSchoolScore = bksSchoolScoreVOS.stream().max(Comparator.comparing(BksSchoolScoreVO::getMinSection)).get();
        System.out.println("----------:" + bksSchoolScore);
        BksSchoolScoreVO bksSchoolScore1 = bksSchoolScoreVOS.stream().min(Comparator.comparing(BksSchoolScoreVO::getMinSection)).get();
        System.out.println("----------:" + bksSchoolScore1);

    }
}
